<template>
  <div id="user-filter">
    <div class="profile" v-if="JSON.stringify(currentUser) !== '{}'">
      <slot></slot>
    </div>
    <div class="user-empty" v-else>
      <div>暂未登录，<a @click.prevent="login">请登录</a></div>
    </div>
  </div>
</template>

<script >
export default {
  name: "userFilter",
  props: {
    currentUser: Object,
  },
  methods: {
    login() {
      this.$router.push({
        path: "/login",
      });
    },
  },
};
</script>

<style scoped>
.user-empty a {
  text-decoration: underline;
  color: red;
}
</style>